home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
network
/
pktdrvtp.zip
/
PKTDRVR.ZIP
/
PKTDRVR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-08
|
26KB
|
653 lines
UNIT PKTDRVR;
{
╔════════════════════════════════╤═════════════════════════════════════╗
║ Filename : PKTDRVR.PAS │ Program / Unit : [U] ║
║ Description : Turbo Pascal └─────────────────────────────────────╢
║ Object to interface with Crynrware packet drivers. ║
║ ║
╟──────────────────────────────────────────────────────────────────────╢
║ Compiler : Turbo Pascal 7.0 ║
║ OS-Version : MS-DOS 6.0 ║
║ Last edit : 08-Oct-93 ║
║ Version : 1.0 ║
╟──────────────────────────────────────────────────────────────────────╢
║ Author : Oliver Rehmann ║
║ Copyright : (C) 1993 Oliver Rehmann ║
║ ║
║ Released to public domain. ║
║ The author can not be held responsible for any damages resulting ║
║ from the use of this software. ║
╚══════════════════════════════════════════════════════════════════════╝
}
INTERFACE
USES DOS,OBJECTS;
{$I PACKET.INC}
CONST
Pkt_Sig : String[08] = 'PKT DRVR';
ParamLen : Byte = 14;
TYPE TPKTSTATUS = (NO_PKTDRVR,INITIALIZED,NOT_INITIALIZED);
TACCESSTYPE = RECORD
if_class : Byte; { Interface class }
if_type : Word; { Interface Type }
if_number : Byte; { Interface number }
type_ : Pointer;
typelen : Word; { length of type_, set to 0 if
you want to receive all pkts }
receiver : Pointer; { receive handler }
END;
TPKTPARAMS = RECORD
major_rev : Byte; { Major revision ID of packet specs }
minor_rev : Byte; { Minor revision ID of packet specs }
length : Byte; { Length of structure in Bytes }
addr_len : Byte; { Length of a MAC address }
mtu : Word; { MTU, including MAC headers }
multicast_aval: Word; { buffer size for multicast addr. }
rcv_bufs : Word; { (# of back-to-back MTU rcvs) - 1 }
xmt_bufs : Word; { (# of successive xmits) - 1 }
int_num : Word; { Interrupt # to hook for post-EOI
processing, 0 == none }
END;
TDRVRINFO = RECORD
Version : Word; { Packet driver version }
Class : Byte; { Driver class }
Type_ : Word; { Driver type }
Number : Byte; { Driver number }
pName : Pointer;
Functionality : Byte; { How good is this driver }
END;
TSTATISTICS = RECORD
packets_in : LongInt;
packets_out : LongInt;
bytes_in : LongInt;
bytes_out : LongInt;
errors_in : LongInt;
errors_out : LongInt;
packets_lost : LongInt;
END;
TPKTDRVR = OBJECT(TOBJECT)
private
pktInt : Integer;
pktHandle : Integer;
pktRecvHandler : Pointer;
pktStatus : TPKTSTATUS;
pktError : Byte;
pktRegs : Registers;
pktAccessInfo : TACCESSTYPE;
PROCEDURE TestForPktDriver;
public
CONSTRUCTOR Init(IntNo : Integer);
DESTRUCTOR Done; VIRTUAL;
PROCEDURE ScanForPktDriver;
FUNCTION GetStatus : TPKTSTATUS;
FUNCTION GetError : Byte;
FUNCTION GetHandle : Word;
PROCEDURE GetAccessType (VAR pktAccessType : TACCESSTYPE);
PROCEDURE DriverInfo (VAR pktInfo : TDRVRINFO );
PROCEDURE AccessType (VAR pktAccessType : TACCESSTYPE);
PROCEDURE ReleaseType;
PROCEDURE TerminateDriver;
PROCEDURE GetAddress (Buffer : Pointer;BufLen : Word; VAR BufCopied : Word);
PROCEDURE ResetInterface;
PROCEDURE GetParameters (VAR pktParams : TPKTPARAMS);
PROCEDURE SendPkt (Buffer : Pointer;BufLen : Word );
PROCEDURE As_SendPkt (Buffer : Pointer;BufLen : Word;Upcall : Pointer );
PROCEDURE SetRCVmode (Mode : Word);
FUNCTION GetRCVmode : Word;
PROCEDURE SetMulticastList(VAR mcList : Pointer; VAR mcLen : Word);
PROCEDURE GetMulticastList(VAR mcList : Pointer; VAR mcLen : Word);
PROCEDURE GetStatistics (VAR pktStatistics : TSTATISTICS );
PROCEDURE SetAddress (Address : Pointer; VAR AddrLen : Word);
END;
IMPLEMENTATION
{╔══════════════════════════════════════════════════════════════════════╗
║ CONSTRUCTOR Init ║
╟─────────────────┬────────────────────────────────────────────────────╢
║ Description : │ Initializes packet driver object ║
║ │ ║
╟─────────────────┼────────────────────────────────────────────────────╢
║ Creation date : │ 13-SEPT-93 ║
╚═════════════════╧════════════════════════════════════════════════════╝}
CONSTRUCTOR TPKTDRVR.Init(IntNo : Integer);
BEGIN
Inherited Init;
pktInt := IntNo;
pktStatus := NOT_INITIALIZED;
FillChar(pktAccessInfo,SizeOf(pktAccessInfo),#00);
TestForPktDriver;
END;
{╔══════════════════════════════════════════════════════════════════════╗
║ DESTRUCTOR Done ║
╟─────────────────┬────────────────────────────────────────────────────╢
║ Description : │ Calls inherited destructor of TOBJECT ║
║ │ ║
╟─────────────────┼────────────────────────────────────────────────────╢
║ Creation date : │ 13-SEPT-93 ║
╚═════════════════╧════════════════════════════════════════════════════╝}
DESTRUCTOR TPKTDRVR.Done;
BEGIN
{ Release allocated handle }
IF (pktStatus = INITIALIZED) THEN
BEGIN
ReleaseType;
END;
Inherited Done;
END;
{╔══════════════════════════════════════════════════════════════════════╗
║ FUNCTION GetStatus : TPKTSTATUS ║
╟─────────────────┬────────────────────────────────────────────────────╢
║ Description : │ Returns current object status ║
║ │ ║
╟─────────────────┼────────────────────────────────────────────────────╢
║ Creation date : │ 13-SEPT-93 ║
╚═════════════════╧════════════════════════════════════════════════════╝}
FUNCTION TPKTDRVR.GetStatus : TPKTSTATUS;
BEGIN
GetStatus := pktStatus;
END;
{╔══════════════════════════════════════════════════════════════════════╗
║ FUNCTION GetAccessType ║
╟─────────────────┬────────────────────────────────────────────────────╢
║ Description : │ Returns information about type of interface, class,║
║ │ interface number. ║
╟─────────────────┼────────────────────────────────────────────────────╢
║ Creation date : │ 13-SEPT-93 ║
╚═════════════════╧════════════════════════════════════════════════════╝}
PROCEDURE TPKTDRVR.GetAccessType(VAR pktAccessType : TACCESSTYPE);
BEGIN
pktAccessType := pktAccessInfo;
END;
{╔══════════════════════════════════════════════════════════════════════╗
║ PROCEDURE TestForPktDriver; ║
╟─────────────────┬───────────────────────────────────────────────────